﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WITM.DAL
{
    public class SpendingCategoryRepository : ISpendingCategoryRepository
    {
        private WhereIsTheMoneyDBEntities context;

        public SpendingCategoryRepository(WhereIsTheMoneyDBEntities dbcontext)
        {
            context = dbcontext;
        }

        #region ISpendingCategoryRepository Members

        public IEnumerable<SpendingCategories> GetAll()
        {
            return context.SpendingCategories.ToList();
        }

        public IEnumerable<SpendingCategories> Find(System.Linq.Expressions.Expression<Func<SpendingCategories, bool>> where)
        {
            return context.SpendingCategories.Where(where).ToList();
        }

        public SpendingCategories First(System.Linq.Expressions.Expression<Func<SpendingCategories, bool>> where)
        {
            return context.SpendingCategories.FirstOrDefault(where);
        }

        public void Add(SpendingCategories category)
        {
            context.AddToSpendingCategories(category);
        }

        public void Delete(SpendingCategories category)
        {
            throw new NotImplementedException();
        }

        public void Attach(SpendingCategories category)
        {
            context.Attach(category);
        }

        #endregion
    }
}
